import axios from 'axios';
import {req, reqfile} from './axiosFun';

/**
 * 运维工具
 **/

/*
监控脚本
*/
// 查询正常主机
export const devHostList = (params) => {return req("get", "/api/dev/hostall/", params)};

// 监控脚本-保存（添加编辑）
export const monitorpySave = (params) => {return req("put", "/api/dev/monitorpy/" + params.id + '/', params)};
// 监控脚本-保存（新增）
export const monitorpyAdd = (params) => {return reqfile("post", "/api/dev/monitorpy/upload_file/", params)};
// export const monitorpyAdd = (params) => { return req("post", "/api/devops/monitorpy/upload_file/", params) };
// 获取机器的脚本数据
export const monitorpyList = (params) => {return req("get", "/api/dev/monitorpy/", params)};
export const monitorpyPage = (params) => {return req("get", "/api/dev/monitorpy/?page=" + params.currentPage + "&limit=" + params.pageSize)};
export const monitorpyDelete = (params) => {return axios.delete("/api/dev/monitorpy/" + params + '/').then(res => res.data)};
export const monitorpySearch = (params) => {return req("get", "/api/dev/monitorpy/?host_ip=" + params.var_lable__icontains + '&search=' + params.var_name__icontains)};

// 修改文件
// 获取文件内容
export const configsInfo = (params) => {
  return req("post", "/api/dev/configs/pull_info/", params)
};
export const configsPushInfo = (params) => {
  return req("post", "/api/dev/configs/push_info/", params)
};
export const getLinuxCommands = (params) => {
  return req("post", "/api/dev/configs/get_linux_commands/", params)
};

// 文件分发
export const filesFork = (params) => {return reqfile("post", "/api/dev/file_fork/send_file/", params)};
export const delay_Textarea = (params) => {return reqfile("get", "/api/dev/file_fork/delay_textarea/", params)};
export const varName = (params) => {return req("get", "/api/dev/file_fork/", params)};
export const verBack = (params) => {return req("post", "/api/dev/file_fork/back_file/", params)};

// 日志审计
export const logsList = (params) => {return req("get", "/api/dev/logs/", params)};
export const logsListPage = (params) => {return req("get", "/api/dev/logs/?page=" + params.currentPage + "&limit=" + params.pageSize)};
export const logsSearch = (params) => {return req("get", "/api/dev/logs/?&search=" + params.var_name__icontains)};


